package com.wolfpire.system.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
@Entity
@Table(name = "t_knowledge")
public class Knowledge implements Serializable {

	/**
	 * 知识点实体
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", unique = true, nullable = false, length = 16)
	private Long id;//主键Id
	
	@Column(name = "name", length = 75)
	private String name; //知识点名称
	
	@Column(name = "parent_id", length = 32)
	private Long parentId; //父知识点ID
	
	@Column(name = "join_name", length = 500)
	private String joinname; //知识点名称
	
	@Column(name = "leaf")
	private boolean leaf = true; // 是否是叶子节点 true 是, flase 否
	
	@Column(name = "remark", length = 255)
	private String remark; //备注
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time")
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")  
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") 
	private Date createTime = new Date(); //创建时间
	
	@Transient
	private String state;
	
	@Transient
	private Long _parentId;
	
	@Transient
	private String text;
	
	@Transient
	private Long subjectId; //所属学科Id
	
	@Transient 
	private Long professionId; //所属专业

	public Knowledge() {
		super();
		// TODO Auto-generated constructor stub
	}

	public Knowledge(String name) {
		super();
		this.name = name;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Long getParentId() {
		return parentId;
	}

	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}

	public boolean isLeaf() {
		return leaf;
	}

	public void setLeaf(boolean leaf) {
		this.leaf = leaf;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Long get_parentId() {
		_parentId = this.parentId;
		return _parentId;
	}

	public void set_parentId(Long _parentId) {
		this._parentId = _parentId;
	}

	public String getText() {
		text = this.name;
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Long getSubjectId() {
		return subjectId;
	}

	public void setSubjectId(Long subjectId) {
		this.subjectId = subjectId;
	}

	public String getJoinname() {
		return joinname;
	}

	public void setJoinname(String joinname) {
		this.joinname = joinname;
	}
	
	
	public String getState() {
		state = (this.leaf ? "open" : "closed");
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public Long getProfessionId() {
		return professionId;
	}

	public void setProfessionId(Long professionId) {
		this.professionId = professionId;
	}
	
}
